package demo02;

import com.mysql.jdbc.JDBC4Connection;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;

/*
    自定义的连接对象
 */
public class MyConnection1 extends JDBC4Connection {
    //1.声明连接对象和连接池集合对象
    private Connection con;
    private List<Connection> pool;

    //通过构造方法给成员变量赋值
    public MyConnection1(String hostToConnectTo, int portToConnectTo, Properties info, String databaseToConnectTo, String url) throws SQLException {
        super(hostToConnectTo, portToConnectTo, info, databaseToConnectTo, url);
        this.con=con;
        this.pool=pool;
    }
    //重写close方法,将连接归还给池中


    @Override
    public void close() throws SQLException {
        pool.add(con);
    }
}
